$scriptDir = (split-path $myinvocation.mycommand.path -parent)

$dir = $env:windir + "\system32\inetsrv"

Set-Location $dir
$apps = .\appcmd.exe list config /section:system.webServer/fastCgi /xml

$found = $FALSE;

$phpXml = [xml] $apps;
$applicationNodes = $phpXml.SelectNodes("//application[@fullPath[contains(.,'php-cgi.exe')]]");
$count = [int] $applicationNodes.Count;

if ($count -gt 0)
{
    $phpDir = [System.IO.Path]::GetDirectoryName($applicationNodes.Item(0).fullPath);  
}  

Set-Location $scriptDir

if ($phpDir -ne "")
{	
    $phpIni = [System.IO.Path]::Combine($phpDir, "php.ini");
    
    $configurations = Get-Content "$phpIni"

	foreach($config in $configurations)
	{
		if($config -like "*extension*=*php_sqlsrv*" -and -not $config.Trim().StartsWith(';'))
		{
		   $found = $TRUE;
		   break;
		}
	}   
}

$found;